%%

%class Scanner
%implements TokenKinds
%function nextToken
%type Token
%state COMMENTSTATE

%unicode
%line
%column

%{
 
/**
   * Utility methode om een token te maken.
   * @param kind token soort
   * @see TokenKinds
   */
  private Token createToken(int kind) {
    return new Token(kind,yyline+1,yycolumn+1,yytext());
  }
 
%}
LineTerminator = \r|\n|\r\n
WhiteSpace     = {LineTerminator} | [ \t\f]
Terminal		= [a-zA-Z]*
NonTerminal		= "<"{Terminal}">"
ISDEFINEDAS		= "::=" 
Empty			= "EMPTY"
OR				= "|"



%%

<YYINITIAL> {

<<EOF>>         {return createToken(EOF);}
{LineTerminator} {return createToken(EOL);}
{WhiteSpace}    {}
{Empty}			{return createToken(EMPTY);}
{Terminal}		{return createToken(TERMINAL);}
{NonTerminal}	{return createToken(NONTERMINAL);}
{ISDEFINEDAS} 	{return createToken(IS_DEFINED_AS);}
{OR}			{return createToken(OR);}



}

.|\n            {throw new RuntimeException(yytext()+" unmatched");}
